package leetcode100;

import java.util.Scanner;

/**
 * @author shkstart
 * @create 2022-12-22-23:13
 */
public class Meme20_2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            String a = in.next();
            String b = in.next();
            System.out.println(method(a,b));
        }
    }
    public static int method(String n,String m){
        char[] x = n.toCharArray();
        char[] y = m.toCharArray();
        int max = 0;
        int[][]arr = new int[x.length+1][y.length+1];

        for(int i=1;i<=x.length;i++){
            for(int j =1;j<=y.length;j++){
                if(x[i-1]==y[j-1]){
                    arr[i][j]=arr[i-1][j-1]+1;

                    if(arr[i][j]>max){
                        max =arr[i][j];
                    }
                }

            }
        }
        return max;
    }
}
